/***********************************************************************************************************************************
 * Name:	Quest_Performance_Repository_Stats.sql
 * Author:	Frank Figearo (frank@sqlnerd.me)
 * Summary:	Check the time range of stored performance metrics.
 */
SET IMPLICIT_TRANSACTIONS OFF; WHILE 0 < @@TRANCOUNT ROLLBACK;
USE Quest_Performance_Repository;
GO
SELECT
	ID.INSTANCE_KEY		AS [Instance ID],
	ID.HOST				AS [Host Name],
	ID.INSTANCE_NAME	AS [InstanceName],
	RT.RESOLUTION_TYPE	AS [Resolution Type],
	RT.NAME				AS [Resolution],
	PL.AVAIL_FIRST_TIME	AS [First_Available_Time],
	PL.AVAIL_LAST_TIME	AS [Last_Available_Time]
  FROM QUEST_INSTANCE_DIM ID
	INNER JOIN QUEST_CTRL_PYRAMID_LEVELS PL ON (ID.INSTANCE_KEY = PL.INSTANCE_KEY)
	INNER JOIN QUEST_CTRL_RESOLUTION_TYPES# RT ON (PL.RESOLUTION_TYPE = RT.RESOLUTION_TYPE)
  GROUP BY ID.INSTANCE_KEY, ID.HOST, ID.INSTANCE_NAME, RT.RESOLUTION_TYPE, RT.NAME, PL.AVAIL_FIRST_TIME, PL.AVAIL_LAST_TIME
  ORDER BY ID.HOST, RT.RESOLUTION_TYPE;
GO